//教练评价数据


import React, { useEffect, useState } from 'react';
import { Layout, Row, Col, Card, Statistic, Table, Rate } from 'antd';
import { getCoachDataAPI } from '@/api/admin/dataStatistics';

const { Header, Content } = Layout;

const data = [
  {
    coachId: '1',
    coachName: '张教练',
    rating: 4,
    comment: '教学经验丰富，耐心指导，推荐！',
  },
  {
    coachId: '2',
    coachName: '李教练',
    rating: 3,
    comment: '教学效果一般，希望能改进。',
  },
  {
    coachId: '3',
    coachName: '王教练',
    rating: 5,
    comment: '非常满意，教学方法很好！',
  },
];

const columns = [
  {
    title: '教练',
    dataIndex: 'coachName',
    key: 'coachName',
  },
  {
    title: '评分',
    dataIndex: 'rating',
    key: 'rating',
    render: rating => <Rate disabled defaultValue={rating} />,
  },
  {
    title: '评论',
    dataIndex: 'comment',
    key: 'comment',
  },
];

const CoachEvaluation = () => {
  const [coachData,setCoachData] =useState([])
  useEffect(()=>{
    async function getCoachData(){
      const res = await getCoachDataAPI()
      const data=res.data
      if(data !=='')
        setCoachData(data)
    }
    getCoachData()
  },[])
  return (
    <Layout>
     <Header style={{  textAlign: 'center' }}>
     <h1 style={{ color: 'white' ,fontSize: '1.5rem'}}>教练评价数据统计分析</h1>
      </Header>
      <Content style={{ padding: '20px' }}>
        <Row gutter={16}>
          <Col span={8}>
            <Card>
              <Statistic title="教练总数" value={coachData.length} />
            </Card>
          </Col>
          <Col span={8}>
            <Card>
              <Statistic title="平均评分" value={Math.round(coachData.reduce((acc, cur) => acc + cur.rating, 0) / coachData.length)} />
            </Card>
          </Col>
          {/* You can add more statistics cards here based on your requirements */}
        </Row>
        <br />
        <Card title="教练评价数据表格">
          <Table dataSource={coachData} columns={columns} />
        </Card>
      </Content>
    </Layout>
  );
};

export default CoachEvaluation;